import { displayByName } from "./effectController"

// 全选，控制所有站点，站线
export const controlAll = (isChecked, subLineData) => {
    const checked = isChecked
    const lineNames = subLineData.value.map(item => item.name)
    const stationNames = []
    subLineData.value.forEach(item => {
        const { stationsList } = item
        stationsList.forEach(station => {
            stationNames.push(station.name)
        })
    })
    // 控制地图元素显示隐藏
    displayByName(lineNames, stationNames, checked)
    // 控制ui面板显示隐藏
    subLineData.value = subLineData.value.map(item => {
        item.checked = checked
        return item
    })
}

// 单独控制站线
export const chooseLine = (item) => {
    console.log(item)
    const names = [item.name]
    const stationNames = item.stationsList.map(station => station.name)
    // 控制ui面板显示隐藏
    item.checked = !item.checked
    console.log(item)
    // 控制地图元素显示隐藏
    displayByName(names, stationNames, item.checked)
}